import { Component, Injectable } from '@angular/core';
import { MdDialog,MdDialogRef,MdSnackBar } from '@angular/material';
import {
  DeleteConfirmComponent
} from '../general/pop/delete-confirm.component';

@Injectable()
export class DialogService {

    constructor(public dialog: MdDialog,public snackBar: MdSnackBar) { }

    openAlert(Component?) {
        this.dialog.open(Component ? Component : LoadingCompoennt);
    }
/* 弹出弹窗*/
    openConfirm(Compoent,option?){
         let dialogRef = this.dialog.open(Compoent,option) ;
         return dialogRef
    }

    closeDialog(){
        this.dialog.closeAll();
    }
  openDeleteConfirm(data={} ) {
    let pro = this.dialog.open(DeleteConfirmComponent, {
      data: data
    })
    return pro
  }

    openSnackBar(message: string, action: string) {
    this.snackBar.open(message, action, {
      duration: 2000,
    });
  }


}

@Component({
  selector: 'dialog-overview-example-dialog',
  template: `
    <div style='display: flex;flex-direction: column; align-items: center;'>
    <md-spinner style="width:40px;height:40px;color:#2196f3"></md-spinner>
    loading...
    </div>
  `,
})
export class LoadingCompoennt {}

@Component({
  selector: 'delete-confirm',
  template: `
    <h1 md-dialog-title>删除确认</h1>
    <div md-dialog-content>确认删除该分组吗</div>
    <div md-dialog-actions>
    <button md-button style='background:#2196f3;color:white;margin-right: 30px;' md-dialog-close="yes">确认</button>
    <button md-button md-dialog-close="No">取消</button>
    </div>
  `,
})
export class DeleteManaConfirm {
    constructor(public dialogRef: MdDialogRef<DeleteManaConfirm>) { }
}

@Component({
  selector: 'delete-confirm',
  template: `
    <h1 md-dialog-title>删除确认</h1>
    <div md-dialog-content>确认删除该任务吗</div>
    <div md-dialog-actions>
    <button md-button style='background:#2196f3;color:white;margin-right: 30px;' md-dialog-close="yes">确认</button>
    <button md-button md-dialog-close="No">取消</button>
    </div>
  `,
})
export class DeleteTaskConfirm {
    constructor(public dialogRef: MdDialogRef<DeleteTaskConfirm>) { }
}


